package com.zhitongyun.devlop.ui;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.Toast;

import com.ramotion.paperonboarding.PaperOnboardingEngine;
import com.ramotion.paperonboarding.PaperOnboardingPage;
import com.ramotion.paperonboarding.listeners.PaperOnboardingOnChangeListener;
import com.ramotion.paperonboarding.listeners.PaperOnboardingOnRightOutListener;
import com.zhitongyun.devlop.R;

import java.util.ArrayList;

/**
 * Created by huanglei on 5/27/16.
 */
public class SplashScreenActivity extends Activity {

    private Activity activity;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.activity = this;
        setContentView(R.layout.onboarding_main_layout);

        final PaperOnboardingEngine engine = new PaperOnboardingEngine(findViewById(R.id.onboardingRootView), getDataForOnboarding(), getApplicationContext());
        engine.setOnChangeListener(new PaperOnboardingOnChangeListener() {
            @Override
            public void onPageChanged(int oldElementIndex, int newElementIndex) {
                Toast.makeText(getApplicationContext(), oldElementIndex + " -> " + newElementIndex, Toast.LENGTH_SHORT).show();
            }
        });

        engine.setOnRightOutListener(new PaperOnboardingOnRightOutListener() {
            @Override
            public void onRightOut() {
                startActivity(new Intent(activity, HomeActivity.class));
                finish();
            }
        });

    }

    // Just example data for Onboarding
    private ArrayList<PaperOnboardingPage> getDataForOnboarding() {
        // prepare data
        PaperOnboardingPage scr1 = new PaperOnboardingPage("功能1", "通过插件方式来浏览app",
                Color.parseColor("#678FB4"), R.mipmap.ic_launcher, R.mipmap.wallet);
        PaperOnboardingPage scr2 = new PaperOnboardingPage("功能2", "没想好",
                Color.parseColor("#65B0B4"), R.mipmap.ic_launcher, R.mipmap.wallet);
        PaperOnboardingPage scr3 = new PaperOnboardingPage("功能3", "没想好",
                Color.parseColor("#9B90BC"), R.mipmap.ic_launcher, R.mipmap.wallet);

        ArrayList<PaperOnboardingPage> elements = new ArrayList<>();
        elements.add(scr1);
        elements.add(scr2);
        elements.add(scr3);
        return elements;
    }

}
